<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>004原生js_求两个数组的交集</title>
</head>
<body>
    <script>
        let arr = [1,2,2,3,3,4,4,5,5]
        let arr2 = [3,4,5,6,7]

        let temp = []
        let same = []
        for(let i = 0; i < arr.length; i++) {
            for(let j = 0; j < arr2.length; j++) {
                if(arr[i] === arr2[j]) {
                    temp.push(arr[i])
                }
            }
        }
        
        let setArr = new Set(temp)
        for(let v of setArr) {
            same.push(v)
        }
        console.log(setArr, same)
    </script>
</body>
</html>